package com.ruoyi.web.controller.phonecase;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.PcPlatformGallery;
import com.ruoyi.system.service.IPcPlatformGalleryService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台画廊Controller
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/phonecase/platformGallery")
public class PcPlatformGalleryController extends BaseController
{
    @Autowired
    private IPcPlatformGalleryService pcPlatformGalleryService;

    /**
     * 查询平台画廊列表
     */
    @PreAuthorize("@ss.hasPermi('phonecase:platformGallery:list')")
    @GetMapping("/list")
    public TableDataInfo list(PcPlatformGallery pcPlatformGallery)
    {
        startPage();
        List<PcPlatformGallery> list = pcPlatformGalleryService.selectPcPlatformGalleryList(pcPlatformGallery);
        return getDataTable(list);
    }

    /**
     * 导出平台画廊列表
     */
    @PreAuthorize("@ss.hasPermi('phonecase:platformGallery:export')")
    @Log(title = "平台画廊", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PcPlatformGallery pcPlatformGallery)
    {
        List<PcPlatformGallery> list = pcPlatformGalleryService.selectPcPlatformGalleryList(pcPlatformGallery);
        ExcelUtil<PcPlatformGallery> util = new ExcelUtil<PcPlatformGallery>(PcPlatformGallery.class);
        util.exportExcel(response, list, "平台画廊数据");
    }

    /**
     * 获取平台画廊详细信息
     */
    @PreAuthorize("@ss.hasPermi('phonecase:platformGallery:query')")
    @GetMapping(value = "/{galleryId}")
    public AjaxResult getInfo(@PathVariable("galleryId") Long galleryId)
    {
        return success(pcPlatformGalleryService.selectPcPlatformGalleryByGalleryId(galleryId));
    }

    /**
     * 新增平台画廊
     */
    @PreAuthorize("@ss.hasPermi('phonecase:platformGallery:add')")
    @Log(title = "平台画廊", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PcPlatformGallery pcPlatformGallery)
    {
        pcPlatformGallery.setCreateBy(getUsername());
        return toAjax(pcPlatformGalleryService.insertPcPlatformGallery(pcPlatformGallery));
    }

    /**
     * 修改平台画廊
     */
    @PreAuthorize("@ss.hasPermi('phonecase:platformGallery:edit')")
    @Log(title = "平台画廊", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PcPlatformGallery pcPlatformGallery)
    {
        pcPlatformGallery.setUpdateBy(getUsername());
        return toAjax(pcPlatformGalleryService.updatePcPlatformGallery(pcPlatformGallery));
    }

    /**
     * 删除平台画廊
     */
    @PreAuthorize("@ss.hasPermi('phonecase:platformGallery:remove')")
    @Log(title = "平台画廊", businessType = BusinessType.DELETE)
    @DeleteMapping("/{galleryIds}")
    public AjaxResult remove(@PathVariable Long[] galleryIds)
    {
        return toAjax(pcPlatformGalleryService.deletePcPlatformGalleryByGalleryIds(galleryIds));
    }
}

